package com.aote.expression.paramprocessor;

import java.util.Map;

import com.aote.expression.Param;
import com.browsesoft.dbtools.DBTools;
import com.browsesoft.htmlcomponent.HTMLBasicComponent;
import com.browsesoft.user.User;

public class AreacodeProcessor implements ParamProcessor {

	public String process(Param param, Map attribures,
			User loginUser, HTMLBasicComponent component) {	
		Map map = param.getParams();
		String name = (String) map.get("name");
		if (attribures.containsKey(name)) {
			name = (String) attribures.get(name);
			return getCode(name);
		}
		return null;
	}
	private String getCode(String name){
		String result = null;
		String sql = " select f_areacode "
				+ "from t_qucode "
				+ "where f_areaname='" + name + "'";
		try {
			String[][] str = DBTools.executeQueryWithTableHead(sql);
			if (str.length > 1) {
				result = str[1][0]; 
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

}
